home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / utilities / csinvals.lha / CSinVals / CSinVals.doc < prev    next >
Encoding:
Text File  |  1992-09-02  |  7.5 KB  |  184 lines

  1.  
  2.                 ·C·O·D·E·X· ·D·E·S·I·G·N· ·S·O·F·T·W·A·R·E·
  3.                  presents:
  4.  
  5.                          Create Sinus Values V1.00
  6.                                - CSinVals -
  7.  
  8.                     programmed 15.9.1994 by Hans Bühler
  9.                    (c)1994 Codex Design Software (Amiga)
  10.                             all rights reserved
  11.  
  12.                                  -I- Intro
  13.  
  14.                                  I.1. Idea
  15.  
  16.  This program is dedicated to those who want easily FAST calculate sinus
  17. or cosinus values from a specific angle. It bases on an idea mainly used
  18. in assembly programms, I assume:
  19.  One stores each sinus value from 0° to 360° degrees (or in any range he
  20. needs) in a WORD or LONGWORD area, multiplied by a secific value,in most
  21. cases you would choose a power of 2, maybe 256 = 2^8.
  22.  Then, let's say, you want to calculate a rotation of P(Px|Py) by an an-
  23. gel of 75°, you just calculate:
  24.  
  25.  NewPx = (Px * Sin[75]) / 256 == (px * Sin[75]) >> 8;
  26.  NewPy = (Py * Cos[75]) / 256 == (px * Cos[75]) >> 8 == Py * Sin[75+90];
  27.  
  28. whereby Sin[] is a pointer to an array of some data, might be calculated
  29. using CSinVals V1+.
  30.  This way you trick out the math.lib or the system.
  31.  
  32.                               I.2. The trick
  33.  
  34.  This program, CSinVals, is needed to create these sinus data values,and
  35. it offers much options allowing the user to modify these data the way he
  36. wants to.
  37.  
  38.                          I.3. System requirements
  39.  
  40.  CSinVals V1+ will work on every Amiga equipped with Kick2.0 or higher.
  41.  
  42.  
  43.  
  44.                                -II- Program
  45.  
  46.                              II.1. Parameters
  47.  
  48.  CSinVals is a very ;) simple commandline command,offering the following
  49. options (AmigaDOS keywords parsed by ReadArgs()).
  50.  Due the source is added,one may change the code in order to run it with
  51. Kick1.2 or anything.
  52.  
  53.  This is the commandline:
  54.  
  55.  CSinVals C-FILE/A,
  56.           LABEL/K,COSLAB/K,
  57.           START/K/N,COUNT/K/N,STEP/K/N,
  58.           MULTI/K/N,ADD/K/N,
  59.           CHAR/S,SHORT/S,LONGINT/S,
  60.           OVERWRITE/S
  61.  
  62. Introduction to the parameters:
  63.  
  64.  C-FILE/A is the only really required arument.It defines the destination
  65.              file used to store the ASCII C-Language output in.
  66.              CSinVals V1.00 WON'T extend the file's name by '.c' ; do it
  67.              yourself !
  68.              If you don't use option OVERWRITE additionally, you will be
  69.              requested whether to delete an already existing file,always.
  70.  
  71.  LABEL=<Label>  says CSinVals to use the string <Label> as label for the
  72.              Sinus-Array. Defaults to [SinValues].
  73.  COSLAB=<Label> says CSinVals to additionally create a label for the Co-
  74.              sinus datas (the number of values , set by COUNT will auto-
  75.              matically rised by 90/STEP to gurantee that Cos[Angel] will
  76.              work).
  77.              NOTE: I assume, that the compiler you are going to use will
  78.                    put data arrays that are *listened* behind each other
  79.                    will be compiled laying behind each other.
  80.                    If you are not sure,I advise you NOT to use the opt.,
  81.                    but rise COUNT by '90/STEP' and use this preprocessor
  82.                    command:
  83.                     #define CosValues(ANGEL) SinValues[(90/STEP)+ANGEL]
  84.                    This will always work correcly.
  85.              Default is NO label.
  86.  
  87.  START=<start_with_angel> defines the first angel to get a sinus()-value
  88.              from. The angel will NOT be taken as radians.
  89.              Defaults to [0].
  90.  COUNT=<number_of_values> says CSinVal how much values you need.Remember
  91.              that using 'COSLAB=' would increase the number of values by
  92.              90/STEP.
  93.              Defaults to [360/STEP].
  94.  STEP=<difference_between_to_angels>  says CSinVal what it has to add to
  95.              the previous angel .  In fact , it's how fine you need your
  96.              values.
  97.              Defaults to minimum [1].
  98.  
  99.  MULTI=<mutliply_each_value_by> makes CSinVal multiplying each sin-value
  100.              by this number.  It might be useful to have powers of 2 for
  101.              this number : Thus you can easily shift right the result of
  102.              any calculations by the power itself.
  103.              Let's say you have MULTI=128 and you want to calculate
  104.                  NewVal = 100 * sin(75), do:
  105.                  NewVal = (100 * SinDat[75]) >> 7;
  106.              ...and everything is fine.
  107.              Default is [256=2^8].
  108.  ADD=<add_to_each_value> forces CSinVal to add the number specified here
  109.              to each value (after MULTIplication !).
  110.              Use this e.g. to fix values beeing negative.
  111.              Default is [0].
  112.  
  113.  CHAR (switchable) forces to store all data in an char array.
  114.              NOTE: CSinVal  will not check whether any value exceeds the
  115.                    limits of the data class !!!!!!!!!!!
  116.  SHORT (switchable) same for word array.
  117.  LONGINT (switchable) same for long integer data class.
  118.              Defaults to [SHORT].
  119.  
  120.  OVERWRITE (switchable) disables requesting for file already existing.
  121.              Be careful !
  122.              You might destroy data you will never get back !
  123.              Defaults is to get confirmation from the user first.
  124.  
  125.                             II.2. A little test
  126.  
  127.  Let's say you need the Sinus()- and Cosinus()-values for an amplifier ,
  128. minimum angel of 20° , maximum of 160° , and  you are sure you only need
  129. each 2nd value, that means two inputs differ by not less than 2.  You do
  130. not want to much trouble, so you want to multiply each value by 512=2^9.
  131.  You want to save these data in file called  'CoSinus.c' ,  offering two
  132. BYTE labels 'CosData[]' and 'SinData[]' to the linker.
  133.  Moreover, because you want to generate these data by your 'smakefile' ,
  134. you neither need output nor any confirmation whether to overwrite an old
  135. file (you are sure you know where you put the data):
  136. In this case, COUNT isused to be COUNT=(160-20)/2=70
  137.  
  138.  CSinVal >NIL: CoSinus.c START=20 COUNT=70 STEP=2 MULTI=512
  139.                          LABEL=SinData COSLABEL=SinData
  140.                          CHAR OVERWRITE
  141.  
  142.  Now get a new amplifier's position offset (a is the len of the vector):
  143. (remember 'extern UBYTE SinDat[],CosDat[];')
  144.  
  145.            / Ax(Alpha) \   / (a * SinDat[Alpha >> 1]) >> 9) \
  146. A(Alpha) = |           | = |                                |
  147.            \ Ay(Alpha) /   \ (a * CosDat[Alpha >> 1]) >> 9) /
  148.  
  149.  
  150.  
  151.                             -III- Postscriptum
  152.  
  153.                              III.1. Copyrights
  154.  
  155.     This program, its source and this little text is copyrighted by the
  156.    author. He reserves all rights for himself, while allowing everybody
  157.         to copy this program for his own private or commercial use.
  158.    It is not permitted to change anything within the program, the source
  159.                    or the documentation. It is my work !
  160.       Any responsibilty for damage to hard- or software inflicted by
  161.           the use or misuse of this program is given to the user.
  162.       I can't and won't ever gurantee anything concerning the effects
  163.                          caused by this program !
  164.  
  165.                               III.2. History
  166.  
  167. 15.9.1994 initial version. Supports CLI argument parsing; no bugs found.
  168.  
  169.                                III.3. Future
  170.  
  171.                      - Generate assembly source, too.
  172.  
  173.                             III.4. Additionals
  174.  
  175.                    Codex Design Software, Amiga section
  176.                                 Hans Bühler
  177.                        Kirchstr.22, 10557 Berlin 21
  178.                                  FRGermany
  179.                call +49(0)30 393 38 14 or +49(0)30 392 79 42
  180.  
  181.  
  182.                                    BYE.
  183.  
  184.